import { EntitySchema } from '@mikro-orm/core';

export class LePromoterCommission {
  id!: string;
  beneficiary!: string;
  orderGoodsId!: string;
  commission?: string;
  level?: boolean = true;
  createdTime?: number = 0;
  updatedTime?: number = 0;
  deletedTime?: number = 0;
  isDeleted?: number = 0;
  salesAmount?: string;
}

export const LePromoterCommissionSchema = new EntitySchema({
  class: LePromoterCommission,
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    beneficiary: { type: 'string', columnType: 'bigint', index: '受益人ID' },
    orderGoodsId: { type: 'string', columnType: 'bigint', index: '分销订单ID' },
    commission: {
      type: 'string',
      columnType: 'numeric(10,2)',
      nullable: true,
      defaultRaw: `0.00`,
    },
    level: { type: 'boolean', nullable: true, default: true },
    createdTime: { type: 'number', nullable: true, default: 0 },
    updatedTime: { type: 'number', nullable: true, default: 0 },
    deletedTime: { type: 'number', nullable: true, default: 0 },
    isDeleted: { type: 'number', columnType: 'tinyint', nullable: true, default: 0 },
    salesAmount: {
      type: 'string',
      columnType: 'numeric(10,2)',
      nullable: true,
      defaultRaw: `0.00`,
    },
  },
});
